<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/laypage.css">
    <script src="/js/vue/vue.min.js"></script>
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/laypage/laypage.js" charset="utf-8"></script>
    <script src="/js/layer/layer.js" charset="utf-8"></script>
    <style>
        #lib {
            width: 100%;
            margin: 0px auto;
         }
        ol li {
            text-align: center;
            list-style-type: none;
            width: 125px;
            font-size: 15px;
            text-align: center;
            display: inline-block;
            cursor:pointer;
        }
        th{
            height: 30px;
            line-height: 30px;
            font-size: 14 px;
        }
        .pro_name{
            width: 160px;
            display: -webkit-box;
           -webkit-box-orient: vertical;
           -webkit-line-clamp: 1;
            overflow: hidden;
            }
        }
    </style>
</head>
<body>
<div id="app" class="container">
    <div  class="container">
        <table>
        <#--题库-->
            <tr>
             <td class="point"><label>题库</label></td>
             <td>
               <ol id="lib">
                <#list listLib as listLib>
                <li  id="lib_id" onclick="findLib(${listLib.lib_id})">${listLib.lib_name}</li>
                </#list>
               </ol>
                 <input type="hidden" id="lay_lib" value="0"/><#--临时储存lib_id-->
             </td>
         </tr>
        <#--知识点-->
              <tr>
                <td><label class="point">知识点</label></td>
                <td>
                   <ol id="point">
                       <li id="point_id" @click="findPoint(res.point_id)" v-for="res in re" style="display:inline-block">{{res.point_name}}</li>
                   </ol>
                    <input type="hidden" id="lay_point" value="0"/> <#--临时储存根据题库point_id-->
                </td>
              </tr>
            <#--题型-->
          <tr>
               <td class="point"><label>题型</label></td>
               <td width=>
                     <ol id="type">
                     <#list listType as listType>
                      <li id="type_id" onclick="findType(${listType.type_id})">${listType.type_name}</li>
                     </#list>
                       </ol>
                     <input type="hidden" id="lay_type" value="0"/> <#--临时储存type_id-->
               </td>
          </tr>
        </table>
    </div>
    <div class="table-responsive">
        <table class="table">
            <thead>
            <tr class="success">
                <th width="100">试题编号</th>
                <th width="100">题目</th>
                <th width="100">出题时间</th>
                <th width="100">题类型</th>
                <th width="100">所属题库</th>
                <th width="120">所属知识点</th>
                <th width="100">难度等级</th>
                <th width="100"> 出题老师</th>
                <th width="100">试题修改</th>
                 <th width="100">查看详情</th>
                 <th width="100">试题删除</th>
            </tr>
            </thead>
            <tbody>
            <tr class="active" v-for="(item,index) in result">
                <td width="60">{{item.pro_id}}</td>
                <td width="220" class="pro_name">{{item.pro_name}}</td>
                <td width="100">{{item.date}}</td>
                <td width="100">{{item.type.type_name}}</td>
                  <td width="100">{{item.lib.lib_name}}</td>
                <td width="100">{{item.point.point_name}}</td>
                <td>{{item.grade}}</td>
                <td width="100">{{item.teacher.teacher_name}}</td>
            <#--td>A {{item.pro_mapname.A}}&nbsp;B{{item.pro_mapname.B}}</td>-->
                <td width="100"><a href="#" @click="editEvent(item.pro_id)">修改</a></td>
                <td width="100"><a href="#" @click="search(item.pro_id)">查看</a></td>
                <td width="130"><a href="#" @click="delEvent(item.pro_id)">删除</a></td>
            </tr>
            </tbody>
            <tr>
                <td colspan="3">
                    <div id="pagenav"></div>
                </td>
            </tr>
        </table>
    </div>
</div>
<script>

    var app = new Vue({
        el: '#app',
        data: {
            result:[],
             re:[]
        },
    });

    var getProblemPageList = function (curr) {
        var lib_id = $("#lay_lib").val();
        var point_id = $("#lay_point").val();
        var type_id = $("#lay_type").val();
        $.ajax({
            type: 'GET',
            dataType: 'json',
            url: '/problem/getPage.do',
            data: {
                pageNum: curr || 1,
                pageSize: 8,
                "lib.lib_id": lib_id,
                "point.point_id": point_id,
                "type.type_id": type_id
            },
            success: function (msg) {
                app.result = msg.page;
                app.re = msg.listP;
                laypage({
                    skin: '#FFB6C1',
                    cont: 'pagenav', //容器。值支持id名、原生dom对象，jquery对象,
                    pages: msg.totalPage, //总页数
                    first: "第一页",
                    last: "最后一页",
                    curr: curr || 1, //当前页
                    jump: function (obj, first) { //触发分页后的回调
                        if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                            getProblemPageList(obj.curr);
                        }
                    }
                });
            }
        });
    }
    getProblemPageList();
    /*查看试题*/
    var search = function (pro_id) {
        layer.open({
            type: 2,
            title: '查看试题',
            fix: false,
            maxmin: true,
            shadeClose: true,
            area: ['900px', '600px'],
            content: '/problem/searchProblem.do?pro_id=' + pro_id,
            end: function () {
                getProblemPageList();
            }
        });
    }
    var editEvent = function (pro_id) {
        layer.open({
            type: 2,
            title: '修改试题',
            fix: false,
            maxmin: true,
            shadeClose: true,
            area: ['900px', '600px'],
            content: '/problem/findProblem.do?pro_id=' + pro_id,
            end: function () {
                getProblemPageList();
            }
        });
    }
    /* 删除题*/
    var delEvent = function (pro_id) {
        //删除确认
        layer.confirm('确定删除？', {
                    btn: ['是', '否']
                }, function () {    //如果点击了第一个按钮 ——是
                    $.ajax({
                        type: "GET",
                        dataType: "json",
                        url: "/problem/deleteProblem.do",
                        data: {
                            "pro_id": pro_id
                        },
                        success: function () {
                            getProblemPageList();
                            layer.msg("已经删除了id为" + pro_id + "的记录", {icon: 5});
                        }
                    });
                }
        );
    }
    /*根据点击题型显示知识点并根据题库名筛选*/
    var findLib=function (lib){
        $("#lay_lib").val(lib);
        $("#lay_point").val(0);
            getProblemPageList();
            }
    /*根据点击知识点筛选*/
   var findPoint= function(point){
        $("#lay_point").val(point);
         getProblemPageList();
    }
    /*根据题型筛选*/
    function findType(type){
        $("#lay_type").val(type);
        getProblemPageList();
    }
</script>
</body>
</html>